<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        function goPage() {
            if(!isNaN($("#gogo").val())){
                page($("#gogo").val())
            }
        }

        function page(pn) {
            $("#pageNum").val(pn)
            //alert(pn);
            $("#searchForm").submit();
        }
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("input[name='ckAll']").click(function () {
                if($(this).is(":checked")){
                    $("input[name='ckOne']").attr("checked","checked");
                }else{
                    $("input[name='ckOne']").removeAttr("checked");
                }
            })

            $("input[name='ckOne']").click(function () {
                var count=0;
                $("input[name='ckOne']").each(function (index,domElem) {
                    if($(this).is(":checked")){
                        count++;
                    }
                });
                var allLength=$("input[name='ckOne']").length;
                if(count==allLength){
                    $("input[name='ckAll']").attr("checked","checked");
                }else {
                    $("input[name='ckAll']").removeAttr("checked");
                }
            });
        });
    </script>


</head>
<body>

<form action="/news/findPage.html" method="post" id="searchForm">
    <input type="hidden" name="pageNum" value="" id="pageNum"/>
    <a href="/news/addStr.html">添加新闻</a><br/>
    <table border="1">
        <tr><td>新闻分类：
        <select name="cartigyId">
            <option value="" selected>--请选择--</option>
            <c:forEach items="${cartiys}" var="cart">
            <option value="${cart.id}" ${param.cartigyId==cart.id?"selected":""}>${cart.name}</option>
            </c:forEach>
        </select></td>&nbsp;&nbsp;
            <td>发布时间：<input type="date" name="minDate"/>-<input type="date" name="maxDate"/></td></tr>
        <tr><td>标题：<input type="text" name="title"></td>&nbsp;<td>作者：<input type="text" name="author"></td>
        <td><input type="submit" value="查询"/></td></tr>
    </table>
</form>

<form action="/news/deleteAll.html" method="post">
    <input type="submit" value="批量删除"/>
    <table border="1">
        <tr><td>全选/反选<input type="checkbox" name="ckAll"/></td><td>标题</td><td>作者</td><td>发布时间</td></tr>
        <c:forEach items="${pageInfo.list}" var="news">
            <tr><td><input type="checkbox" name="ckOne" value="${news.id}"/></td><td><a href="#">${news.title}</a></td>
            <td>${news.author}</td>
            <td><fmt:formatDate value="${news.createTime}" pattern="yyyy-MM-dd hh:mm:ss" /></td></tr>
        </c:forEach>
    </table>
</form>



当前第${pageInfo.pageNum}页
共${pageInfo.pages}页
<c:if test="${pageInfo.hasPreviousPage}">
    <a href="#" onclick="page(${pageInfo.pageNum-1})">上一页</a>
</c:if>
<c:forEach items="${pageInfo.navigatepageNums}" var="pn">
    <a href="#" onclick="page(${pn})" style="${pageInfo.pageNum==pn?'color:red':'color:blue'}">${pn}</a>&nbsp;&nbsp;&nbsp;&nbsp;
</c:forEach>
<c:if test="${pageInfo.hasNextPage}">
    <a href="#"  onclick="page(${pageInfo.pageNum+1})">下一页</a>
</c:if>
跳<input size="5" type="text" id="gogo"/>页<input type="button" value="跳转" onclick="goPage()">


</body>

</html>
